package dao;

import java.util.List;

import model.Cbo;

public class DAOCbo extends ModelDAO<Cbo>{
	public DAOCbo() {
        super(Cbo.class);
    }
	
	public void save(Cbo c){
		super.begin();
		super.save(c);
		super.commit();
	}
	
	public List<Cbo> listar(){
		super.begin();
        List<Cbo> list = super.findAll();
        super.commit();
        return list;
    }

	public void update(Cbo c){
		super.begin();
		super.update(c);
		super.commit();
	}
	
	public void delete(Cbo c){
		super.begin();
		super.delete(c.getCodTabelaCBO());
		super.commit();
	}
	
	public Cbo search(int cod){
		super.begin();
		Cbo c = super.search(cod);
		super.commit();
		return c;
	}
	
	public List<Cbo> pesquisarNome(String descCBO){
		super.begin();
		String hql = "select a from Cbo a where a.descCBO like '" + descCBO + "%" + "'";
		List<Cbo> c = super.buscar(hql);
        super.commit();
        return c;
    }
	
	public List<Cbo> pesquisarCod(String codCBO){
		super.begin();
		String hql = "select a from Cbo a where a.codCBO like '" + codCBO + "%" + "'";
		List<Cbo> c = super.buscar(hql);
        super.commit();
        return c;
    }
}
